package com.situ.controller.plan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.situ.service.plan.SalPlanService;
import com.situ.entity.plan.SalPlan;
import com.situ.util.*;
/**
 * SalPlan的路由接口服务
 * 
 * @author胡文
 *
 */
//
@RestController
public class SalPlanController {

	/** SalPlanService服务 */
	@Autowired
	private SalPlanService salPlanService;
	
	/**
	 * 查询所有SalPlan数据的方法
	 * @param value
	 * @return
	 */
	@RequestMapping(value = "/SalPlan/query", produces = {"application/json;charset=UTF-8"})
	public ResponseData query(SalPlan value) {

		return ResponseData.ok().putDataValue("list",salPlanService.find(value));
	}
	
	/**
	 * 通过id查询SalPlan数据的方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "/SalPlan/queryById/{id}", produces = {"application/json;charset=UTF-8"})
	public ResponseData queryById(@PathVariable(name="id") Long id) {
		 return ResponseData.ok().putDataValue("obj",salPlanService.findOne(id));
	}
	
	/**
	 * 插入SalPlan属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "/SalPlan/save")
	public ResponseData save(SalPlan value) {
		return ResponseData.ok().putDataValue("obj", salPlanService.saveNotNull(value));
	}
	
	/**
	 * 更新SalPlan属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "/SalPlan/update", produces = {"application/json;charset=UTF-8"})
	public ResponseData update(SalPlan value) {
		return ResponseData.ok().putDataValue("obj",salPlanService.updateNotNullById(value));
	}

	/**
	 * 通过id删除SalPlan数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "/SalPlan/delById/{id}", produces = {"application/json;charset=UTF-8"})
	public ResponseData delById(@PathVariable(name="id") Long id) {
		return ResponseData.ok().putDataValue("obj",salPlanService.deleteById(id));
	}


    //带分页的查询全部
//@ApiOperation("带分页的查询全部")
/*
    @RequestMapping(value = "/SalPlan/queryPage", produces = {"application/json;charset=UTF-8"})
    public ResponseData queryPage(SalPlan value,
                             @RequestParam(defaultValue = "1",required = false) int pageNum ,
                             @RequestParam(defaultValue = "5",required = false) int pageSize) {

	    PageHelper.startPage(pageNum, pageSize);
        List<SysMight> list = sysMightService.find2(value);
    PageInfo pageInfo = new PageInfo<SysMight>(list,5);

        return ResponseData.ok()
        // .putDataValue("list", list)
        .putDataValue("pageInfo",pageInfo);
        }
 */
/*
根据外键查询
 */
    @RequestMapping(value = "/SalPlan/wjId/{id}", produces = {"application/json;charset=UTF-8"})
    public ResponseData wjId(@PathVariable(name="id") Long id) {
        String ii="211";
        return ResponseData.ok().putDataValue("list",salPlanService.findOne2(id));

    }
}
